#!/usr/bin/env python
from optparse import OptionParser
import sys
from pyday import database
from pyday import calendar_functions

parser = OptionParser()
parser.add_option("-a", "--add", nargs=4, dest="event", action="store",
                  help="Adds an event to the system")
parser.add_option("--cal-replacement", dest="cal_replacement",
                  action="store_true")

def main():
    (options, args) = parser.parse_args()

    if options.cal_replacement:
        calendar_functions.print_cal_replacement()
        sys.exit()
        
    db = database.Database()
    
    if db.database_exists():
        pass
    else:
        result = db.create_database()
        if result == False:
            print 'Database not found. If you have a backup of an old' \
                  ' database copy it to ~/.pyday or re-run this program' \
                  ' and select y at the prompt.'
            sys.exit
            
    
  

if __name__ == "__main__":
  main()

